package com.runing.service.impl;

import com.runing.config.ResponseWrapper;
import com.runing.entity.RResult;
import com.runing.mapper.RResultMapper;
import com.runing.service.RResultService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lel
 * @since 2021-03-11
 */
@Service
public class RResultServiceImpl extends ServiceImpl<RResultMapper, RResult> implements RResultService {

    @Autowired
    RResultMapper resultMapper;

    public List<RResult> getResult(){
        List<RResult> results = resultMapper.selectList(null);
        return results;
    }

    public ResponseWrapper updateResult(List<RResult> results){
        if ( results.size() == 0){
            return ResponseWrapper.markCustom(false,400,"list不能为空",null);
        }else {
            for (RResult result :results){
              resultMapper.updateById(result);
            }
            return ResponseWrapper.markSuccess(null);
        }

    }

}
